Skip to content

fix: fix error when parsing large definitions#35

Open
glowcloud wants to merge 1 commit intotree-sitter-grammars:masterfrom
glowcloud:fix/large-definition-error
Open

fix: fix error when parsing large definitions#35
glowcloud wants to merge 1 commit intotree-sitter-grammars:masterfrom
glowcloud:fix/large-definition-error

Conversation

@glowcloud
Copy link

Closes #23

Fixes an issue with parsing definitions that have over 32768 lines.

Before:

yaml_before

After:

yaml_after

int16_t row;
int32_t row;
int16_t col;
int16_t blk_imp_row;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int16_t blk_imp_row;
int32_t blk_imp_row;

size += sizeof(int32_t);
scanner->col = *(int16_t *)&buffer[size];
size += sizeof(int16_t);
scanner->blk_imp_row = *(int16_t *)&buffer[size];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scanner->blk_imp_row = *(int16_t *)&buffer[size];
scanner->blk_imp_row = *(int32_t *)&buffer[size];

scanner->col = *(int16_t *)&buffer[size];
size += sizeof(int16_t);
scanner->blk_imp_row = *(int16_t *)&buffer[size];
size += sizeof(int16_t);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size += sizeof(int32_t);

size += sizeof(int32_t);
*(int16_t *)&buffer[size] = scanner->col;
size += sizeof(int16_t);
*(int16_t *)&buffer[size] = scanner->blk_imp_row;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*(int16_t *)&buffer[size] = scanner->blk_imp_row;
*(int32_t *)&buffer[size] = scanner->blk_imp_row;

*(int16_t *)&buffer[size] = scanner->col;
size += sizeof(int16_t);
*(int16_t *)&buffer[size] = scanner->blk_imp_row;
size += sizeof(int16_t);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size += sizeof(int32_t)

@char0n
Copy link

char0n commented Feb 24, 2026

PR changes are not sufficient enough:

blk_imp_row stores a row number (block implicit key row), so it would suffer the same overflow past 32,767 lines. The serialization/deserialization for it (lines 171-172 and 205-206) also still use int16_t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: false error when parsing large definitions

2 participants